package com;

import java.util.Collection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import com.bean.Course;
import com.opensymphony.xwork2.ActionSupport;
import com.service.CourseService;


public class ViewCourses extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Collection<Course> courses;
	
	@Autowired
	@Qualifier("courseService")
	private CourseService courseService;

	public Collection<Course> getCourses() {
		return courses;
	}

	public void setCourses(Collection<Course> courses) {
		this.courses = courses;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	@Override
	public String execute() throws Exception {
		try
		{
			setCourses(courseService.allCourses());
			return SUCCESS;
		} 
		catch (Exception e) 
		{
			e.printStackTrace();
			return ERROR;
		}
	}

}
